import { defineConfig } from 'vitepress'
import renderPermaLink from './render-perma-link'
import MarkDownItCustomAnchor from './markdown-it-custom-anchor'

const ogDescription = 'Next Generation Frontend Tooling'
const ogImage = 'https://vitejs.dev/og-image.png'
const ogTitle = 'SE-UI'
const ogUrl = 'https://vitejs.dev'

export default defineConfig({
  title: 'SE-UI',
  description: 'Uniapp组件库',
  lang: 'zh-CN',
  base: '/seui-docs/',
  head: [
    ['link', { rel: 'icon', type: 'image/svg+xml', href: '/logo.svg' }],
    ['meta', { property: 'og:type', content: 'website' }],
    ['meta', { property: 'og:title', content: ogTitle }],
    ['meta', { property: 'og:image', content: ogImage }],
    ['meta', { property: 'og:url', content: ogUrl }],
    ['meta', { property: 'og:description', content: ogDescription }],
    ['meta', { name: 'twitter:card', content: 'summary_large_image' }],
    ['meta', { name: 'twitter:site', content: '@vite_js' }],
    ['meta', { name: 'theme-color', content: '#646cff' }],
    [
      'script',
      {
        src: 'https://cdn.usefathom.com/script.js',
        'data-site': 'CBDFBSLI',
        'data-spa': 'auto',
        defer: '',
      },
    ],
  ],

  locales: {
    root: { label: '简体中文' },
  },

  themeConfig: {
    logo: '/logo.svg',

    editLink: {
      pattern: '', // https://github.com/vitejs/docs-cn/edit/main/:path
      text: '为此页提供修改建议',
    },

    outline: {
      label: '本页目录'
    },

    socialLinks: [
      { icon: 'github', link: 'https://gitee.com/shiersky/seui' },
    ],

    algolia: {
      appId: '7H67QR5P0A',
      apiKey: 'deaab78bcdfe96b599497d25acc6460e',
      indexName: 'vitejs',
      searchParameters: {
        facetFilters: ['tags:cn']
      },
      placeholder: '搜索文档',
      translations: {
        button: {
          buttonText: '搜索'
        },
        modal: {
          searchBox: {
            resetButtonTitle: '清除查询条件',
            resetButtonAriaLabel: '清除查询条件',
            cancelButtonText: '取消',
            cancelButtonAriaLabel: '取消'
          },
          startScreen: {
            recentSearchesTitle: '搜索历史',
            noRecentSearchesText: '没有搜索历史',
            saveRecentSearchButtonTitle: '保存到搜索历史',
            removeRecentSearchButtonTitle: '从搜索历史中移除',
            favoriteSearchesTitle: '收藏',
            removeFavoriteSearchButtonTitle: '从收藏中移除'
          },
          errorScreen: {
            titleText: '无法获取结果',
            helpText: '你可能需要检查你的网络连接'
          },
          footer: {
            selectText: '选择',
            navigateText: '切换',
            closeText: '关闭',
            searchByText: '搜索供应商'
          },
          noResultsScreen: {
            noResultsText: '无法找到相关结果',
            suggestedQueryText: '你可以尝试查询',
            reportMissingResultsText: '你认为这个查询应该有结果？',
            reportMissingResultsLinkText: '向我们反馈'
          }
        }
      },
    },

    footer: {
      copyright:
        '@SE-UI Uniapp Components',
    },

    nav: [
      { text: '开发指南', link: '/start/', activeMatch: '/start/' },
      { text: '组件', link: '/components/button', activeMatch: '/components/' },
      // { text: '指引', link: '/guide/', activeMatch: '/guide/' },
      // { text: '配置', link: '/config/', activeMatch: '/config/' },
      // { text: '插件', link: '/plugins/', activeMatch: '/plugins/' },
      // {
      //   text: '相关链接',
      //   items: [
      //     { text: 'Team', link: '/team' },
      //     { text: 'Releases', link: '/releases' },
      //     {
      //       text: 'Twitter',
      //       link: 'https://twitter.com/vite_js'
      //     },
      //     {
      //       text: 'Discord Chat',
      //       link: 'https://chat.vitejs.dev'
      //     },
      //     {
      //       text: 'Awesome Vite',
      //       link: 'https://github.com/vitejs/awesome-vite'
      //     },
      //     {
      //       text: 'Dev.to 社区',
      //       link: 'https://dev.to/t/vite'
      //     },
      //     {
      //       text: 'Rollup 插件兼容',
      //       link: 'https://vite-rollup-plugins.patak.dev/'
      //     },
      //     {
      //       text: '更新日志',
      //       link: 'https://github.com/vitejs/vite/blob/main/packages/vite/CHANGELOG.md'
      //     }
      //   ]
      // },
      // {
      //   text: 'Version',
      //   items: [
      //     {
      //       text: 'Vite v3 文档（英文）',
      //       link: 'https://v3.vitejs.dev'
      //     },
      //     {
      //       text: 'Vite v2 文档（英文）',
      //       link: 'https://v2.vitejs.dev'
      //     },
      //   ]
      // }
    ],

    sidebar: {
      '/start/': [
        {
          text: '开发指南',
          items: [
            // {
            //   text: '介绍',
            //   link: '/start/info'
            // },
            {
              text: '快速上手',
              link: '/start/'
            }
          ]
        }
      ],
      '/components/': [
        {
          text: '基础组件',
          items: [
            {
              text: 'Button 按钮',
              link: '/components/button'
            },
            {
              text: 'Icon 图标',
              link: '/components/icon'
            }
          ]
        },
        {
          text: '反馈组件',
          items: [
            {
              text: 'Loading 加载',
              link: '/components/loading'
            }
          ]
        }
      ],
      '/guide/': [
        {
          text: '指引',
          items: [
            {
              text: '为什么选 Vite',
              link: '/guide/why'
            },
            {
              text: '开始',
              link: '/guide/'
            },
            {
              text: '功能',
              link: '/guide/features'
            },
            {
              text: '命令行界面',
              link: '/guide/cli'
            },
            {
              text: '使用插件',
              link: '/guide/using-plugins'
            },
            {
              text: '依赖预构建',
              link: '/guide/dep-pre-bundling'
            },
            {
              text: '静态资源处理',
              link: '/guide/assets'
            },
            {
              text: '构建生产版本',
              link: '/guide/build'
            },
            {
              text: '部署静态站点',
              link: '/guide/static-deploy'
            },
            {
              text: '环境变量与模式',
              link: '/guide/env-and-mode'
            },
            {
              text: '服务端渲染（SSR）',
              link: '/guide/ssr'
            },
            {
              text: '后端集成',
              link: '/guide/backend-integration'
            },
            {
              text: '比较',
              link: '/guide/comparisons'
            },
            {
              text: '故障排除',
              link: '/guide/troubleshooting'
            },
            {
              text: '理念',
              link: '/guide/philosophy',
            },
            {
              text: '从 v3 迁移',
              link: '/guide/migration'
            },
          ],
        },
        {
          text: 'API',
          items: [
            {
              text: '插件 API',
              link: '/guide/api-plugin'
            },
            {
              text: 'HMR API',
              link: '/guide/api-hmr',
            },
            {
              text: 'JavaScript API',
              link: '/guide/api-javascript',
            },
            {
              text: '配置参考',
              link: '/config/'
            }
          ]
        }
      ],
      '/config/': [
        {
          text: '配置',
          items: [
            {
              text: '配置 Vite',
              link: '/config/'
            },
            {
              text: '共享选项',
              link: '/config/shared-options'
            },
            {
              text: '服务器选项',
              link: '/config/server-options'
            },
            {
              text: '构建选项',
              link: '/config/build-options'
            },
            {
              text: '预览选项',
              link: '/config/preview-options'
            },
            {
              text: '依赖优化选项',
              link: '/config/dep-optimization-options'
            },
            {
              text: 'SSR 选项',
              link: '/config/ssr-options'
            },
            {
              text: 'Worker 选项',
              link: '/config/worker-options'
            }
          ]
        }
      ]
    }
  },
})
